package net.zisen.cloud.ping.user.fallback;

import feign.hystrix.FallbackFactory;
import lombok.extern.log4j.Log4j2;
import net.zisen.cloud.base.msg.ResultMsg;
import net.zisen.cloud.ping.user.client.UserServiceClient;
import net.zisen.cloud.ping.user.model.User;
import org.springframework.stereotype.Component;

/**
 * @author tim/278002989@qq.com
 * @Classname UserServiceFallback
 * @Description TODO
 * @Date 2019-05-16 15:33
 */
@Component
@Log4j2
public class UserServiceFallback implements FallbackFactory<UserServiceClient> {
    @Override
    public UserServiceClient create(Throwable throwable) {
        log.error("服务端发生异常：{}", throwable.getMessage());
        return new UserServiceClient() {
            /**
             * 注册用户
             *
             * @param user
             * @return
             * @author time
             */
            @Override
            public ResultMsg registerUser(User user) {
                return ResultMsg.fail().resultCode(500).resultMsg("内部错误！");
            }

        };
    }
}
